From 0f085d76ff55638b68e68bd189fd858d24566211 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 26 Mar 2008 15:50:45 +0000 Subject: [PATCH] x86_emulate: HVM emulation of REP instructions should inject #PF only if virt-to-phys lookup fails for the first repetition. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/emulate.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 9c1a2daeb6..590ce01451 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -74,18 +74,19 @@ static int hvmemul_linear_to_phys( for ( i = 1; done < todo; i++ ) { /* Get the next PFN in the range. */ - if ( (npfn = paging_gva_to_gfn(curr, addr, &pfec)) == INVALID_GFN ) - { - hvm_inject_exception(TRAP_page_fault, pfec, addr); - return X86EMUL_EXCEPTION; - } + npfn = paging_gva_to_gfn(curr, addr, &pfec); /* Is it contiguous with the preceding PFNs? If not then we're done. */ - if ( npfn != (pfn + i) ) + if ( (npfn == INVALID_GFN) || (npfn != (pfn + i)) ) { done /= bytes_per_rep; if ( done == 0 ) - return X86EMUL_UNHANDLEABLE; + { + if ( npfn != INVALID_GFN ) + return X86EMUL_UNHANDLEABLE; + hvm_inject_exception(TRAP_page_fault, pfec, addr); + return X86EMUL_EXCEPTION; + } *reps = done; break; } -- 2.30.2